package com.ptmall.app.ui.activity;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jauker.widget.BadgeView;
import com.ptmall.app.MainActivity;
import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.bean.GoodDetilBean;
import com.ptmall.app.bean.PageData;
import com.ptmall.app.bean.ProductBean;
import com.ptmall.app.bean.ShopCarBean;
import com.ptmall.app.bean.model.HomePageIndex;
import com.ptmall.app.bean.model.db.Account;
import com.ptmall.app.net.HttpMethods;
import com.ptmall.app.net.api.ApiDataRepository;
import com.ptmall.app.net.base.ApiNetResponse;
import com.ptmall.app.ui.adapter.FuwuAdapter;
import com.ptmall.app.ui.adapter.FuwuListAdapter;
import com.ptmall.app.ui.adapter.GoodDetilImgAdapter;
import com.ptmall.app.ui.adapter.GoodDetilimgreAdapter;
import com.ptmall.app.ui.adapter.LikeGoodAdapter;
import com.ptmall.app.ui.adapter.SpecAdapter;
import com.ptmall.app.utils.AllUtils;
import com.ptmall.app.utils.GlideUtil;
import com.ptmall.app.view.FullyLinearLayoutManager;
import com.ptmall.app.view.ImageCycleView;
import com.ptmall.app.view.NoScrollGridView;
import com.ptmall.app.view.NoScrollListView;
import com.ptmall.app.view.PullToRefreshLayout;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GoodDetilActivity extends BaseMvpActivity implements View.OnClickListener {

    String id;

    ImageCycleView banner_img;

    TextView goodname, gooddesc, goodprice, peisong;
    ImageView sc, shoucang, goodimg;

    TextView shopcar_num, guigeyixuan, yixuan, pop_goodprice, pop_goodguige;
    RelativeLayout jia;
    RelativeLayout jian;
    Button addcar;
    Button addcar2;
    GridView spec_gridview;

    GridView fuwu_grid;

    LinearLayout guigeselect;


    PopupWindow popupWindow;
    PopupWindow fuwupop;
    private View popView;
    private View fuwuView;

    GoodDetilBean mGoodDetilBean;

    ApiDataRepository apiDataRepository = ApiDataRepository.getInstance();

    String spec_id,spec_name,sell_price;

    SpecAdapter mSpecAdapter;
    FuwuAdapter mFuwuAdapter;

    RecyclerView img_list;
    GoodDetilimgreAdapter mGoodDetilImgAdapter;

    ImageView gocar,toshopcar;

    NoScrollGridView likelist;
    LikeGoodAdapter likeGoodAdapter;
    LinearLayout fenxiang;

    RelativeLayout rl;
    private PathMeasure mPathMeasure;
    private float[] mCurrentPosition = new float[2];


    private PullToRefreshLayout ptrl;
    int page = 1;
    List<ProductBean> likeArraylist = new ArrayList<>();


    LikeGoodAdapter mLikeGoodAdapter;


    public BadgeView mBadgeView1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_gooddetil);
    }

    @Override
    public void initViews() {
        ptrl = (PullToRefreshLayout) findViewById(R.id.refresh_view);
        img_list = (RecyclerView) findViewById(R.id.img_list);
        fuwu_grid = (GridView) findViewById(R.id.fuwu_grid);
        addcar2 = (Button) findViewById(R.id.addcar);
        guigeyixuan = (TextView) findViewById(R.id.guigeyixuan);
        guigeselect = (LinearLayout) findViewById(R.id.guigeselect);
        sc = (ImageView) findViewById(R.id.sc);
        gocar = (ImageView) findViewById(R.id.gocar);
        banner_img = (ImageCycleView) findViewById(R.id.banner_img);
        gooddesc = (TextView) findViewById(R.id.gooddesc);
        goodname = (TextView) findViewById(R.id.goodname);
        goodprice = (TextView) findViewById(R.id.goodprice);
        peisong = (TextView) findViewById(R.id.peisong);
        fenxiang = (LinearLayout) findViewById(R.id.fenxiang);
        likelist = (NoScrollGridView) findViewById(R.id.likelist);
        rl = (RelativeLayout) findViewById(R.id.rl);
        findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


        mBadgeView1 = new BadgeView(getContext());
        mBadgeView1.setBackground(10, 0xFFFF0000);//色
        mBadgeView1.setTargetView(gocar);
    }

    @Override
    public void initEvents() {
        id = getIntent().getStringExtra("id");
        guigeselect.setOnClickListener(this);
        addcar2.setOnClickListener(this);
        sc.setOnClickListener(this);
        gocar.setOnClickListener(this);
        fenxiang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                apiDataRepository.getUserInfo(null, new ApiNetResponse<Account>(getContext()) {
                    @Override
                    public void onSuccess(Account data) {
                        Intent textIntent = new Intent(Intent.ACTION_SEND);
                        textIntent.setType("text/plain");
                        textIntent.putExtra(Intent.EXTRA_TEXT, data.shareurl);
                        startActivity(Intent.createChooser(textIntent, "分享"));
                    }
                });
            }
        });

        mLikeGoodAdapter = new LikeGoodAdapter(getContext(), likeArraylist);
        likelist.setAdapter(mLikeGoodAdapter);
        mLikeGoodAdapter.setClickInterface(new LikeGoodAdapter.ClickInterface() {
            @Override
            public void shopcaradd(ImageView iv,int position, String id) {
                addcar(id, "1",iv);
            }
        });

        getlike();
        ptrl.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh(PullToRefreshLayout pullToRefreshLayout) {
                page = 1;
                getlike();

            }

            @Override
            public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) {
                page ++;
                getlike();
            }
        });
        getdetil();
    }

    @Override
    protected void onResume() {
        super.onResume();
        getData();
    }

    private void getlike(){
        Map<String,String> map = new HashMap<>();
        map.put("page",page+"");
        apiDataRepository.cnxh(map, new ApiNetResponse<PageData<ProductBean>>() {
            @Override
            public void onSuccess(PageData<ProductBean> data) {

                if (null != ptrl) {
                    ptrl.refreshFinish(PullToRefreshLayout.SUCCEED);
                    ptrl.loadmoreFinish(PullToRefreshLayout.SUCCEED);
                }
                if (page == 1) {
                    likeArraylist.clear();
                }
                if (null != data.getData() && data.getData().size() > 0) {
                    likeArraylist.addAll(data.getData());
                } else {
                }
                mLikeGoodAdapter.pushData(likeArraylist);

            }
        });
    }

    public void getData() {
        apiDataRepository.getShopCarList(null, new ApiNetResponse<PageData<ShopCarBean>>(getContext()) {
            @Override
            public void onSuccess(PageData<ShopCarBean> data) {
                mBadgeView1.setText(data.getCount()+"");
            }
        });
    }


    private void getdetil() {
        Map<String, String> map = new HashMap<>();
        map.put("productId", id);

        ApiDataRepository.getInstance().getGooddetil(map, new ApiNetResponse<GoodDetilBean>(getContext()) {
            @Override
            public void onSuccess(GoodDetilBean data) {

                mGoodDetilBean = data;
                showBanner(data.getSlide());
                goodname.setText(data.getProduct_name());
                gooddesc.setText(data.getIntro());
                goodprice.setText("￥" + data.specs.get(0).sell_price);
                guigeyixuan.setText("已选:"+data.specs.get(0).specs_name);
                spec_id = data.specs.get(0).specsId;
                spec_name = data.specs.get(0).specs_name;
                sell_price = data.specs.get(0).sell_price;
                peisong.setText(data.getPeisong_intro());
                if (data.getCollectId().equals("0")) {
                    sc.setImageResource(R.drawable.sc_false);
                } else {
                    sc.setImageResource(R.drawable.sc_true);
                }
                if(shoucang!=null){
                    if (mGoodDetilBean.getCollectId().equals("0")) {
                        shoucang.setImageResource(R.drawable.sc_false);
                    } else {
                        shoucang.setImageResource(R.drawable.sc_true);
                    }
                }
                List<String> fuwuList = new ArrayList<>();
//                fuwuList.add(data.getPeisong() + "分钟内送达");
                fuwuList.add( "送货到家");
                fuwuList.add(data.getQisong() + "元起送");
                fuwuList.add(data.getMianfei() + "元免运费");
                mFuwuAdapter = new FuwuAdapter(getContext(), fuwuList);
                fuwu_grid.setAdapter(mFuwuAdapter);
                fuwu_grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        fuwupop();
                    }
                });
                mGoodDetilImgAdapter = new GoodDetilimgreAdapter(getActivity());
                mGoodDetilImgAdapter.bind(mGoodDetilBean.getImages());
                FullyLinearLayoutManager linearLayoutManager = new FullyLinearLayoutManager(getContext());
                linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                img_list.setLayoutManager(linearLayoutManager);
                img_list.setAdapter(mGoodDetilImgAdapter);
                img_list.setNestedScrollingEnabled(false);
                img_list.setHasFixedSize(true);
                img_list.setNestedScrollingEnabled(false);
            }
        });
    }


    public void showBanner(List<HomePageIndex.SlideBean> banners) {
        if (banners == null || banners.size() < 1) {
            return;
        }
        banner_img.setImageResources(banners, new ImageCycleView.ImageCycleViewListener() {
            @Override
            public void displayImage(String imageURL, ImageView imageView) {
                //根据图片地址，设置imageView
                // 使用ImageLoader对图片进行加装！
                Glide.with(getActivity()).load(HttpMethods.BASEIMG_URL+imageURL).dontAnimate().placeholder(R.drawable.z2).error(R.drawable.z2).into(imageView);

//                GlideUtil.showImg(getActivity(), imageURL, imageView);
            }

            @Override
            public void onImageClick(HomePageIndex.SlideBean mEntity, int postion, View imageView) {
            }
        });
    }

    private void pop() {
        if (null == popupWindow) {
            if (null == popView) {
                popView = LayoutInflater.from(this).inflate(R.layout.popwindow_goodspec, null);
                jian = (RelativeLayout) popView.findViewById(R.id.shopcar_jian);
                jia = (RelativeLayout) popView.findViewById(R.id.shopcar_jia);
                shopcar_num = (TextView) popView.findViewById(R.id.shopcar_num);
                addcar = (Button) popView.findViewById(R.id.addcar);
                spec_gridview = (GridView) popView.findViewById(R.id.spec_gridview);
                popView.findViewById(R.id.addcar).setOnClickListener(this);
                shoucang = (ImageView) popView.findViewById(R.id.shoucang);
                popView.findViewById(R.id.toshopcar).setOnClickListener(this);
                yixuan = (TextView) popView.findViewById(R.id.yixuan);
                pop_goodprice = (TextView) popView.findViewById(R.id.pop_goodprice);
                pop_goodguige = (TextView) popView.findViewById(R.id.pop_goodguige);
                goodimg = (ImageView) popView.findViewById(R.id.goodimg);
                popView.findViewById(R.id.lin).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popupWindow.dismiss();
                    }
                });
                jian.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        int i = Integer.parseInt(shopcar_num.getText().toString());
                        if (i == 0 || i == 1||i<1) {
                        } else {
                            shopcar_num.setText(--i + "");
//                            addcar(shopcar_num.getText().toString()+"");
                        }
                    }
                });

                jia.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        int i = Integer.parseInt(shopcar_num.getText().toString());
                        shopcar_num.setText(++i + "");
//                        addcar(shopcar_num.getText().toString()+"");
                    }
                });
                addcar.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        popupWindow.dismiss();
                        addcar(shopcar_num.getText().toString());
                    }
                });
                shoucang.setOnClickListener(this);
                mSpecAdapter = new SpecAdapter(getActivity(),mGoodDetilBean.specs);
                mGoodDetilBean.specs.get(0).select = true;
                spec_gridview.setAdapter(mSpecAdapter);
                spec_gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        spec_id = mGoodDetilBean.specs.get(position).specsId;
                        spec_name = mGoodDetilBean.specs.get(position).specs_name;
                        sell_price = mGoodDetilBean.specs.get(position).sell_price;
                        yixuan.setText("已选:" + spec_name);
                        pop_goodprice.setText("￥" + sell_price);
                        pop_goodguige.setText(spec_name);
                        goodprice.setText("￥" + sell_price);
                        guigeyixuan.setText("已选:"+spec_name);
                        for(GoodDetilBean.Specs specs:mGoodDetilBean.specs){
                            specs.select = false;
                        }
                        mGoodDetilBean.specs.get(position).select = true;
                        mSpecAdapter.pushData(mGoodDetilBean.specs);
                    }
                });
            }

            pop_goodprice.setText("￥" + sell_price);
            pop_goodguige.setText(spec_name);
            if (mGoodDetilBean.getCollectId().equals("0")) {
                shoucang.setImageResource(R.drawable.sc_false);
            } else {
                shoucang.setImageResource(R.drawable.sc_true);
            }
            yixuan.setText("已选:" + spec_name);
            if(mGoodDetilBean.getSlide().size()>0){
                GlideUtil.showImg(getContext(), mGoodDetilBean.getSlide().get(0).getImage_path(), goodimg);
            }
//            View view = LayoutInflater.from(this).inflate(R.layout.personaldata_pop, null);
            popupWindow = new PopupWindow(popView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
            popupWindow.setAnimationStyle(R.style.dialogAnim);
            popupWindow.setFocusable(true);
            popupWindow.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
            AllUtils.backgroundAlpha(0.5f, getWindow());
            popupWindow.showAtLocation(popView, Gravity.BOTTOM, 0, 0);
            popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
                @Override
                public void onDismiss() {
                    AllUtils.backgroundAlpha(1.0f, getWindow());
                }
            });
            //popupWindow.showAtLocation(rootView, Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
        } else {
            AllUtils.backgroundAlpha(0.5f, getWindow());
            popupWindow.showAtLocation(popView, Gravity.BOTTOM, 0, 0);
        }
    }

    private void fuwupop() {
        if (null == fuwupop) {
            if (null == fuwuView) {
                fuwuView = LayoutInflater.from(this).inflate(R.layout.popwindow_fuwu, null);
                ListView listView = (ListView) fuwuView.findViewById(R.id.peisong_list);

                List<String> fuwuList = new ArrayList<>();
                fuwuList.add("送货到家");
//                fuwuList.add(mGoodDetilBean.getPeisong() + "分钟内送达");
                fuwuList.add(mGoodDetilBean.getQisong() + "元起送");
                fuwuList.add(mGoodDetilBean.getMianfei() + "元免运费");

                List<String> fuwuList2 = new ArrayList<>();
                fuwuList2.add(mGoodDetilBean.getPeisong_intro());
                fuwuList2.add(mGoodDetilBean.getQisong_intro());
                fuwuList2.add(mGoodDetilBean.getMianfei_intro());

                FuwuListAdapter fuwuListAdapter = new FuwuListAdapter(getContext(), fuwuList, fuwuList2);
                listView.setAdapter(fuwuListAdapter);

                fuwuView.findViewById(R.id.lin).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        fuwupop.dismiss();
                    }
                });
            }
            fuwupop = new PopupWindow(fuwuView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
            fuwupop.setAnimationStyle(R.style.dialogAnim);
            fuwupop.setFocusable(true);
            fuwupop.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));
            AllUtils.backgroundAlpha(0.5f, getWindow());
            fuwupop.showAtLocation(fuwuView, Gravity.BOTTOM, 0, 0);
            fuwupop.setOnDismissListener(new PopupWindow.OnDismissListener() {
                @Override
                public void onDismiss() {
                    AllUtils.backgroundAlpha(1.0f, getWindow());
                }
            });

        }else {
            AllUtils.backgroundAlpha(0.5f, getWindow());
            fuwupop.showAtLocation(fuwuView, Gravity.BOTTOM, 0, 0);
        }
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.sc:
            case R.id.shoucang:
                if (mGoodDetilBean.getCollectId().equals("0")) {
                    addcollection();
                } else {
                    delcollection();
                }
                break;
            case R.id.addcar:
            case R.id.guigeselect:
                pop();
                break;
            case R.id.gocar:
            case R.id.toshopcar:
                Intent intent = new Intent(getContext(), MainActivity.class);
                intent.putExtra("position",2);
                startActivity(intent);
                break;
        }
    }


    private void addcar( String num) {
        Map<String, String> map = new HashMap<>();
        map.put("productId", id);
        map.put("num", num);
        map.put("specsId", spec_id);
        apiDataRepository.addShopCar(map, new ApiNetResponse<Object>() {
            @Override
            public void onSuccess(Object data) {
                showMsg("加入购物车成功");
                getdetil();
                getData();
            }
        });
    }

    private void addcollection() {
        Map<String, String> map = new HashMap<>();
        map.put("productId", id);
        apiDataRepository.addCollection(map, new ApiNetResponse<Object>() {
            @Override
            public void onSuccess(Object data) {
                showMsg("收藏成功");
                getdetil();
            }
        });
    }

    private void delcollection() {
        Map<String, String> map = new HashMap<>();
        map.put("collectIds", mGoodDetilBean.getCollectId());
        apiDataRepository.delCollection(map, new ApiNetResponse<Object>() {
            @Override
            public void onSuccess(Object data) {
                showMsg("取消收藏成功");
                getdetil();
            }
        });
    }


    /**
     * ★★★★★把商品添加到购物车的动画效果★★★★★
     * @param iv
     */
    private void addCartStart( ImageView iv) {
//      一、创造出执行动画的主题---imageview
        //代码new一个imageview，图片资源是上面的imageview的图片
        // (这个图片就是执行动画的图片，从开始位置出发，经过一个抛物线（贝塞尔曲线），移动到购物车里)
        final ImageView goods = new ImageView(getContext());
        goods.setImageDrawable(iv.getDrawable());
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100, 100);
        rl.addView(goods, params);

//        二、计算动画开始/结束点的坐标的准备工作
        //得到父布局的起始点坐标（用于辅助计算动画开始/结束时的点的坐标）
        int[] parentLocation = new int[2];
        rl.getLocationInWindow(parentLocation);

        //得到商品图片的坐标（用于计算动画开始的坐标）
        int startLoc[] = new int[2];
        iv.getLocationInWindow(startLoc);

        //得到购物车图片的坐标(用于计算动画结束后的坐标)
        int endLoc[] = new int[2];
        endLoc[0] = rl.getWidth()/8*4;
        endLoc[1] = rl.getHeight()+100;
//        car.getLocationInWindow(endLoc);


//        三、正式开始计算动画开始/结束的坐标
        //开始掉落的商品的起始点：商品起始点-父布局起始点+该商品图片的一半
        float startX = startLoc[0] - parentLocation[0] + iv.getWidth() / 2;
        float startY = startLoc[1] - parentLocation[1] + iv.getHeight() / 2;

        //商品掉落后的终点坐标：购物车起始点-父布局起始点+购物车图片的1/5
        float toX = endLoc[0] - parentLocation[0];
        float toY = endLoc[1] - parentLocation[1];
        Log.i("location ====","endLoc[]" + endLoc[0] + "  " + endLoc[1]);
        Log.i("location ====","toX[]" + toX + " toY " + toY);
//        四、计算中间动画的插值坐标（贝塞尔曲线）（其实就是用贝塞尔曲线来完成起终点的过程）
        //开始绘制贝塞尔曲线
        Path path = new Path();
        //移动到起始点（贝塞尔曲线的起点）
        path.moveTo(startX, startY);
        //使用二次萨贝尔曲线：注意第一个起始坐标越大，贝塞尔曲线的横向距离就会越大，一般按照下面的式子取即可
        path.quadTo((startX + toX) / 2, startY, toX, toY);
        //mPathMeasure用来计算贝塞尔曲线的曲线长度和贝塞尔曲线中间插值的坐标，
        // 如果是true，path会形成一个闭环
        mPathMeasure = new PathMeasure(path, false);

        //★★★属性动画实现（从0到贝塞尔曲线的长度之间进行插值计算，获取中间过程的距离值）
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, mPathMeasure.getLength());
        valueAnimator.setDuration(500);
        // 匀速线性插值器
        valueAnimator.setInterpolator(new LinearInterpolator());
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                // 当插值计算进行时，获取中间的每个值，
                // 这里这个值是中间过程中的曲线长度（下面根据这个值来得出中间点的坐标值）
                float value = (Float) animation.getAnimatedValue();
                // ★★★★★获取当前点坐标封装到mCurrentPosition
                // boolean getPosTan(float distance, float[] pos, float[] tan) ：
                // 传入一个距离distance(0<=distance<=getLength())，然后会计算当前距
                // 离的坐标点和切线，pos会自动填充上坐标，这个方法很重要。
                mPathMeasure.getPosTan(value, mCurrentPosition, null);//mCurrentPosition此时就是中间距离点的坐标值
                // 移动的商品图片（动画图片）的坐标设置为该中间点的坐标
                goods.setTranslationX(mCurrentPosition[0]);
                goods.setTranslationY(mCurrentPosition[1]);
            }
        });
//      五、 开始执行动画
        valueAnimator.start();

//      六、动画结束后的处理
        valueAnimator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            //当动画结束后：
            @Override
            public void onAnimationEnd(Animator animation) {
                rl.removeView(goods);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }


    private void addcar(String id, String num,ImageView iv) {
        Map<String, String> map = new HashMap<>();
        map.put("productId", id);
        map.put("num", num);
        apiDataRepository.addShopCar(map, new ApiNetResponse<Object>() {
            @Override
            public void onSuccess(Object data) {
                showMsg("加入购物车成功");
                addCartStart(iv);
            }
        });
    }

}
